﻿USE [$o.Database.DatabaseName$]

CREATE TABLE [dbo].[Username_EntityId](
	[Username] [nvarchar](50) NOT NULL,
	[EntityId] [uniqueidentifier] NOT NULL
) 

CREATE UNIQUE CLUSTERED INDEX IDX_Username_EntityId ON  [Username_EntityId]
([Username])

CREATE UNIQUE NONCLUSTERED INDEX IDX_EntityId_Username ON  [Username_EntityId]
([EntityId])


CREATE TABLE [dbo].[Entities](
	[EntityId] [uniqueidentifier] NOT NULL,
	[DataName] [nvarchar](100) NOT NULL,
	[InsertDate] [bigint] NOT NULL,
	[Data] [nvarchar](max) NOT NULL
)

CREATE UNIQUE CLUSTERED INDEX IDX_Entities ON  [Entities]
([EntityId], [DataName], [InsertDate])